home *** CD-ROM | disk | FTP | other *** search
- /* freopen.c, from p. 430 of Turbo C Bible */
- #include <stdio.h>
- main()
- {
- char filename[81];
- printf("enter file name where output sould go: ");
- gets(filename);
- printf("If all goes well, use TYPE %s to see \ result.\n", filename);
- /* Redirect stdout to this file */
- if (freopen(filename, "w", stdout) == NULL)
- {
- printf("freopen failed.\n");
- exit(0);
- }
- /* Print some lines */
- printf("Redirexting stdout to the file %s\n", filename);
- printf("All output will be in this file.\n");
- }